package cn.yj.core.business.controller;

import cn.yj.cgs.dba.entity.Message;
import cn.yj.config.web.AppBaseController;
import cn.yj.core.business.service.iservice.IMessageService;
import cn.yj.entity.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author 永健
 * @since 2021-06-16 11:42
 */
@RestController
@RequestMapping("/message")
public class MessageController extends AppBaseController<Message> {
    @Resource
    private IMessageService messageService;

    @GetMapping("/pageList")
    public R pageList() {
        return success(messageService.pageList(getMap("userCode", getUserCode()), page()));
    }

    @GetMapping("/noRead")
    public R noRead() {
        return success(messageService.countNoRead(getUserCode()));
    }

    @PostMapping("/read/{ids}")
    public R read(@PathVariable Integer[] ids) {
        return success(messageService.read(getUserCode(),Arrays.asList(ids)));
    }
}
